<template>
  <div class="imageList">
    <div class="list"  v-if="data && data.length>0">
      <div class="item" v-for="item in data" :style="{width:width+'px',height:height+'px'}">
        <img :src="item.source===2?item.url:webCfg.api.url+':'+webCfg.api.fileSvrPort+'/'+item.url" style="width: 100%; height: 100%;" @click="viewBigImg($event)">
        <p class="name">{{item.name}}</p>
        <p class="state" v-show="item.state && item.state!=='正常'">{{item.state}}</p>
      </div>
    </div>
    <div v-else style="color:#666; display: flex; align-items: center; justify-content: center" :style="{height:height*3+'px'}">
      查询结果为空！
    </div>
    <div class="page">
      <slot></slot>
    </div>
  </div>
</template>

<script>

  export default {
    name: "ImageList",
    components: {

    },
    props: ['data'],
    data() {
      return {
        webCfg:WebCfg,
        width: 0,
        height: 0,
      }
    },
    mounted() {
      this.init();
    },
    methods: {
      init() {
        const W = window.screen.width;
        this.width = W / 4 ;
        this.height = W / 4 * 9 / 16 - 20 ;
      },
      viewBigImg(e) {
        this.$kkui.dialog({
          width: '90%',
          height: '90%',
          cont: `<img src="${e.currentTarget.getAttribute('src')}" style="width:100%; height100%;object-fit:contain;" />`
        })
      },
    }
  }
</script>

<style scoped lang="scss">
  .imageList {
    display: flex;
    flex-direction: column;
    height: 100%;

    .list {
      display: flex;
      flex-wrap: wrap;

      .item {
        border: 1px solid #000;
        box-sizing: border-box;
        position: relative;
        cursor: pointer;

        .name {
          position: absolute;
          bottom: 5px;
          left: 5px;
          text-align: center;
          font-size: 14px;
          font-weight: 600;
          text-shadow: -1px -1px 1px #333, 1px 1px 1px #999;
        }

        .state{
          position: absolute;
          top: 5px;
          right: 5px;
          text-align: center;
          font-size: 14px;
          font-weight: 600;
          color:#999;
          text-shadow: -1px -1px 1px #333, 1px 1px 1px #000;
        }
      }
    }

    .page {
      flex: 1;
      display: flex;
      align-items: center;
      justify-content: center;
      text-align: center;
    }

    /deep/ .blackBg .el-pagination {
      .el-input__inner {
        background-color: #101010;
        border-color: rgba(255, 255, 255, .1);
        color: #006AA5;
        font-weight: 600;
      }

      .btn-next, .btn-prev {
        background: center center no-repeat #222;
        border: 1px solid #222;
        color: #555;
      }

      .btn-next:hover, .btn-prev:hover {
        color: var(--title-color)
      }

      button:disabled {
        color: #555 !important;
      }

      .el-pager li {
        background-color: #101010;
        border: 1px solid #111;
      }
    }
  }
</style>
